package com.example.repository;


import com.example.entity.Department;
import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import javax.transaction.Transactional;
import java.util.*;

//部门DAO
@Transactional //开启事务，才能进行删除操作
public interface DepartmentRepository extends JpaRepository<Department,Integer> {
    //添加部门 save



    //通过UserId得到所有部门
    List<Department> findAllByUserId(Integer userId);

    //通过部门id和UserId得到部门
    Department findByIdAndUserId(Integer id,Integer userId);

    //删除部门
    void deleteByIdAndUserId(Integer id,Integer userId);

}
